<?php require_once('../../core/import.php');?>
<?php User::Permission('ROLE_UPDATE'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/kindeditor/import.kindeditor.js"></script>
    <script type="text/javascript" src="scripts/role.edit.js"></script>
</head>

<body>
	<?php
    #赋值检测
    if(!is_numeric($ID=Functions::UrlArgs('id'))) exit('信息ID不正确');
    
    #获取数据
    $Data=DB::GetRowByID('management_user_role',$ID);
    {
	?>
    <form id="Form1" name="Form1" method="post" action="role.edit.action.php" class="Form">
        <fieldset>
            <legend>管理员修改</legend>
            <table width="100%" cellpadding="1" cellspacing="0">
            <tr>
                <td width="130" height="25" align="left">
                	角色名称：
                </td>
                <td width="915" colspan="2">
                 <input type="text" id="Name" name="Name" value="<?php echo $Data['Name'] ?>" class="Textbox" /> 
                </td>
            </tr>
            </table>
        </fieldset>
	<table width="100%" cellpadding="1" cellspacing="0">
      	<?php
            $Modular=DB::GetRows('select Identifying,Name,Role,URL,Identifying_Parent from management_user_permission where Identifying_Parent is null or Branch=1 order by RealSort asc');
		?>
        <input type="hidden" value="<?php echo count($Modular) ?>" name="is_i"/>
        <?php
                  for($i=0;$i<count($Modular);$i++)
                  {
           			if(intval($i%2)==intval(0)){
					echo '<tr>';
					} 
		?>
            
            <td width="48%">
        	 <fieldset>
           	 <legend><?php echo $Modular[$i]['Name'] ; ?><input type="checkbox" name="Modular[]" value="<?php echo $Modular[$i]['Role']; ?>" <?php if(in_array($Modular[$i]['Role'],explode(',',$Data['Permissions']))){?> checked="checked" <?php } ?> onclick="MemberCheck(<?php echo $i;?>);"/></legend>
           	 <table width="100%" cellpadding="1" cellspacing="0">
             <tr>
             <?php
            $Function=DB::GetRows('select Identifying,Name,Role,URL,Identifying_Parent from management_user_permission where Identifying_Parent is not null and Identifying_Parent='.$Modular[$i]['Identifying'].' order by ID asc');
                  for($j=0;$j<count($Function);$j++)
                  {
		?>
                  <td>
                        <?php echo $Function[$j]['Name']?><input type="checkbox" name="Function_<?php echo $i?>[]" value="<?php echo $Function[$j]['Role'] ?>" <?php if(in_array($Function[$j]['Role'],explode(',',$Data['Permissions']))){?> checked="checked" <?php } ?>/>
                  </td>
		<?php
           		if(intval(($j+1)%4)==intval(0)){
				echo '</tr>';
            	}
           }
            ?>
             </table>
             </fieldset>
           </td>
           <?php
           		if(intval($i%2)==intval(0)){
				echo '<td width="4%">&nbsp;</td>';
			}
           		if(intval($i%2)!=intval(0)){
				echo '</tr>';
            	}
           }
            ?>    
	</table>
		<input type="hidden" name="ID" value="<?php echo $ID ?>" />
        <input id="ActionButton" name="ActionButton" type="submit" value="确定" class="button" /> <input id="ResetButton" name="ResetButton" type="reset" value="重置" class="button" />
    </form>
    <?php	
    }
    $Data=NULL;
	?>
</body>
</html>